---
layout: example
category: example
title: Swipe between maps
description: 'Use <a target="_blank" href="https://github.com/mapbox/mapbox-gl-compare">mapbox-gl-compare</a> to swipe between map instances &amp; sync their movement.'
---
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-compare/v0.0.1/mapbox-gl-compare.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-compare/v0.0.1/mapbox-gl-compare.css' type='text/css' />
<style>
body {
    overflow: hidden;
}

body * {
   -webkit-touch-callout: none;
     -webkit-user-select: none;
        -moz-user-select: none;
         -ms-user-select: none;
             user-select: none;
}

.map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}
</style>

<div id='before' class='map'></div>
<div id='after' class='map'></div>

<script>
var before = new mapboxgl.Map({
    container: 'before',
    style: 'mapbox://styles/mapbox/light-v8',
    center: [0, 0],
    zoom: 0
});

var after = new mapboxgl.Map({
    container: 'after',
    style: 'mapbox://styles/mapbox/dark-v8',
    center: [0, 0],
    zoom: 0
});

new mapboxgl.Compare(before, after);
</script>
